<template>
  <div class="footer" :class="{pc:pcClass}">
    <p><span class="error-icon">!</span>您也可以拨打我们的客服电话进行相关咨询。</p>
    <div class="call-box">
      <div @click="callQQ" v-if="qq" class="qq-box">
        <span class="qq-icon"></span>
        <span>在线QQ咨询</span>
      </div>
      <div @click="callPhone">
        <img src="../assets/img/kf.png" alt="">
        <span>{{tel}}</span>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  data() {
    return {
      pcClass: false
    }
  },
  computed: {
    ...mapState({
      tel: s => s.serviceInfo.tel,
      qq: s => s.serviceInfo.qq
    })
  },
  created() {
    if (!this.$getDeviceInfo().isPhone && document.documentElement.getBoundingClientRect().width > 560) {
      this.pcClass = true
    }
  },
  methods: {
    callQQ() {
      window.location.href = "http://wpa.qq.com/msgrd?v=3&uin=" + this.qq + "&site=qq&menu=yes"
    },
    callPhone() {
      if (this.$getDeviceInfo().isPhone) {
        window.location.href = 'tel:' + this.tel
      }
    }
  }
}
</script>
<style lang='scss' scoped>
.footer {
  width: 100%;
  height: 1.6rem;
  background-color: #f8f7f5;
  padding: 0 0.66rem;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  .qq-icon {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    background: url(../assets/img/qq.png) center no-repeat;
    background-size: contain;
    vertical-align: middle;
    margin-right: 0.14rem;
  }
  &.pc {
    width: 560px;
    left: 50%;
    transform: translate3d(-280px, 0, 0);
  }
  p {
    font-size: 0.26rem;
    line-height: 0.76rem;
    // text-align: center;
    color: rgba(191, 191, 191, 1);
    text-align: center;
    .error-icon {
      width: 0.26rem;
      height: 0.26rem;
      line-height: 0.26rem;
      color: #fff;
      background-color: #bebebe;
      border-radius: 50%;
      font-size: 0.2rem;
      text-align: center;
      display: inline-block;
      vertical-align: middle;
      margin-right: 0.1rem;
    }
    img {
      width: 0.26rem;
      height: auto;
      vertical-align: middle;
    }
  }
  .call-box {
    display: flex;
    justify-content: center;
    span {
      font-size: 0.34rem;
      line-height: 0.34rem;
      font-weight: bold;
      color: rgba(115, 158, 251, 1);
      vertical-align: middle;
    }
    img {
      margin-right: 0.14rem;
      width: 0.26rem;
      height: auto;
      vertical-align: -0.1rem;
    }
  }
  .qq-box {
    margin-right: 0.9rem;
  }
}
</style>
